package com.designpatterns.singleton;

/**
 * @author Brook
 */
public class Singleton3 {
    private volatile static Singleton3 uniqueInstance;

    private Singleton3() {};

    /**
     * 双重检查锁，减少getInstance同步，减小性能损耗，
     * 1.4及更早版本不可用
     */
    public static Singleton3 getInstance() {
        if(uniqueInstance == null){
            synchronized (Singleton3.class){
                uniqueInstance = new Singleton3();
            }
        }
        return uniqueInstance;
    }



}

